﻿@{
    /*
     统一的文件上传接口，统一的调用规则，直接将本文件放到Shared目录即可
     */
    Layout = null;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>HTTP统一上传入口</title>
    <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
    <script type="text/javascript">
        /* 调用主页面的方法，用来显示主页面的图像 */
        var Url = "@ViewBag.Url";
        var ParentImgInput = "@ViewBag.ParentImgInput";
        var ParentImgSrc = "@ViewBag.ParentImgSrc";
        var FileName = "@ViewBag.FileName";

        if (Url != '') {//提交之后要执行的
            if (window.parent.document.getElementById(ParentImgInput)) {
                window.parent.document.getElementById(ParentImgInput).value = Url;
            }
            if (window.parent.document.getElementById(ParentImgSrc)) {
                window.parent.document.getElementById(ParentImgSrc).setAttribute("src", Url);
            }
            if (window.parent.document.getElementById(FileName))
                window.parent.document.getElementById(FileName).value = "@ViewBag.FileNameValue";
        }
    </script>
    <style type="text/css">
        .btn {
            background: url("/Content/images/filter_btn.gif") repeat scroll 0 0 transparent;
            border: medium none;
            cursor: pointer;
            height: 24px;
            margin: 0;
            width: 55px;
            color: #fff;
        }
    </style>
</head>
<body style="margin: 0px;">
    <div class="type-file-box">
        <form id="Upload" method="post" enctype="multipart/form-data">
        <!--可扩展的隐藏域-->
        <input type="hidden" name="ParentImgSrc" id="ParentImgSrc"  value="@ViewBag.ParentImgSrc"/>
        <input type="hidden" name="ParentImgInput" id="ParentImgInput"  value="@ViewBag.ParentImgInput"/>
        <input type="hidden"  name="ImageWidth"  id="ImageWidth" value="@ViewBag.ImageWidth"/>
        <input type="hidden"  name="ImageHeight"  id="ImageHeight" value="@ViewBag.ImageHeight"/>
        <input type="hidden"  name="FileName"  id="FileName" value="@ViewBag.FileName"/>
        <input type="hidden" name="IsCompletePath" id="IsCompletePath"  value="@ViewBag.IsCompletePath" />
        <input type="hidden" name="UploadPath" id="UploadPath"  value="@ViewBag.UploadPath" />
        <table border="0" cellpadding="0" cellspacing="0" width="400">
            <tr>
                <td width="250">
                    <input type="file" id="pic" name="pic" class="type-file-file" value="@ViewBag.Url"/>
                </td>
                <td>
                    <input type="submit" value="上  传" />
                </td>
                <td width="100">
                    <span id="msg" style="color: Red; padding-left: 5px;">@ViewBag.Msg</span>
                </td>
            </tr>
        </table>
        </form>
    </div>
</body>
</html>
